# encoding: UTF-8
"""

@author = 李林名
@email = lishuai1199@qq.com
@create_time = 2022/11/24 16:38

"""

from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
from selenium.webdriver.support.ui import Select


# #1.对select点击:   先打印当前选中的老师的名字，再选择小雷老师
# wd = webdriver.Chrome()
# wd.get('https://cdn2.byhy.net/files/selenium/test2.html')
# ##根据属性选择元素,并打印对应老师名
# element= wd.find_element(By.CSS_SELECTOR,'#ss_single  [selected="selected"]')
# print("当前select选择的老师为:",element.get_attribute('value'))
#
# ##选择并打印小雷老师
# select=Select(wd.find_element(By.CSS_SELECTOR,'#ss_single'))
# select.select_by_visible_text('小雷老师')
# sleep(1)


# #2.对select多选:  只是选择小江老师和小雷老师
# wd = webdriver.Chrome()
# wd.get('https://cdn2.byhy.net/files/selenium/test2.html')
# ##根据属性选择元素,并打印对应老师名
# element= wd.find_element(By.CSS_SELECTOR,'#ss_multi  [selected="selected"]')
# print("当前select选择的老师为:",element.get_attribute('value'))
#
# ##取消小雷老师,并选择小江老师和小雷老师
# select=Select(wd.find_element(By.CSS_SELECTOR,'#ss_multi'))
# select.deselect_all()
# select.select_by_visible_text('小雷老师')
# select.select_by_visible_text('小江老师')
# sleep(5)